#ifndef PUSHGATEWAY_CLIENT_H
#define PUSHGATEWAY_CLIENT_H

#include "php_pushgateway.h"

#include "scaler.h"
#include "push_init.h"
#include "helper.h"
#include "push_utils.h"

#include <algorithm>
#include <map>
#include <string>
#include <thread>
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <vector>
#include <cmath>
#include <regex>

using namespace std;

struct push_value
{
    int decimal;
    long value;
};

// pushgateway客户端
class client
{
private:
    client(){};

public:
    map<string, map<string, map<string, map<string, map<string, push_value>>>>> data; // url -> type -> key -> index -> item -> value
    bool runnable = true;
    bool debug = false;
    char *output = nullptr;
    static client *instance;
    string currentPushUrl();
    void setData(string type, string key, string index, string item, long step, int decimal);
    void setData(string type, string key, string index, string item, long step);
    void setData(string type, string key, string index, string item);
    static client *newInstance();
    static void send(int interval, int p_timeout, int p_connecttimeout);
    void syncSend();
    void run(int interval);
    void setCounter(scaler *sc);
    void setBucket(scaler *sc, double seconds, string bk);
    void clean();
    string toString(string url);
    void test();
};

#endif